Skip to content

Add list deconstruction similar to Lisp for function arguments.#148

Closed
Habush wants to merge 4 commits into
trueagi-io:mainfrom
Habush:main
Closed

Add list deconstruction similar to Lisp for function arguments.#148
Habush wants to merge 4 commits into
trueagi-io:mainfrom
Habush:main

Conversation

@Habush
Copy link
Copy Markdown
Contributor

@Habush Habush commented Mar 24, 2026

  • Adds list deconstruction similar to Lisp with . operator. This will provide a syntactic sugar of the form (= (sum ($head . $rest) )...))
  • Add is-ground/1 predicate for checking if an expression is a ground expression. A complement to the already existing is-var/1 predicate.

Copy link
Copy Markdown
Collaborator

@patham9 patham9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, sure it should be infix?
In what way is it better than the already supported (cons $head $tail) pattern?
A testcase would be needed to see I guess.

@patham9
Copy link
Copy Markdown
Collaborator

patham9 commented Mar 25, 2026

The is-ground looks good though!

@patham9
Copy link
Copy Markdown
Collaborator

patham9 commented Apr 2, 2026

Thank you though! Can we have is-ground by itself for now in this PR @Habush ? Then I am happy to merge it

@Habush
Copy link
Copy Markdown
Contributor Author

Habush commented Apr 2, 2026

In what way is it better than the already supported (cons $head $tail) pattern?

It was a style choice as it is common list deconstruction pattern in Lisp-like languages. But I understand if infix operators don't match PeTTa's style. I have removed the operator and the PR now contains only is-ground.

Copy link
Copy Markdown
Collaborator

@patham9 patham9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm is-ground also needs to be registered I suppose? Do you have a testcase for it?

@patham9
Copy link
Copy Markdown
Collaborator

patham9 commented May 9, 2026

@Habush if you register the function we can merge the PR

@patham9 patham9 added this to the v1.0.3 milestone May 9, 2026
Habush added 2 commits May 9, 2026 21:01
Signed-off-by: Abdulrahman S. Omar <hsamireh@gmail.com>
@Habush
Copy link
Copy Markdown
Contributor Author

Habush commented May 9, 2026

Registered the function. Please check

@patham9
Copy link
Copy Markdown
Collaborator

patham9 commented May 12, 2026

It also removes is-alpha-member, why?

@Habush
Copy link
Copy Markdown
Contributor Author

Habush commented May 12, 2026

Oops, that was by mistake. I'll close this PR and create a now for a cleaner commit history

@Habush Habush closed this May 12, 2026
@Habush
Copy link
Copy Markdown
Contributor Author

Habush commented May 12, 2026

Closed in favor #172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants